from rest_framework import serializers

from apps.goods.models import SKU
from apps.orders.models import OrderInfo, OrderGoods




# 这是订单序列化器的定义



class SKUSerializer(serializers.ModelSerializer):
    default_image_url  = serializers.ImageField(source='default_image')
    class Meta:
        model = SKU
        fields = ['default_image_url','name',]
class OrderGoodsSerializer(serializers.ModelSerializer):
    sku = SKUSerializer()
    class Meta:
        model = OrderGoods
        fields = '__all__'
class OrderSerializer(serializers.ModelSerializer):
    skus = OrderGoodsSerializer(many=True)
    class Meta:
        model = OrderInfo
        fields = '__all__'
# 这是详情视图序列化器的定义
class OrderSSerializer(serializers.ModelSerializer):
    class Meta:
        model = OrderInfo
        fields = ['status']